package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.FaceDb;
import com.xmy.cultivate.mapper.FaceDbMapper;
import com.xmy.cultivate.service.IFaceDbService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 人脸数据库 服务实现类
 * </p>
 *
 * @author hpiggy
 * @since 2024-03-20
 */
@Service
public class FaceDbServiceImpl extends ServiceImpl<FaceDbMapper, FaceDb> implements IFaceDbService {

    @Value("${aliyun.face.DbName}")
    String faceDbname;

    @Value("${systype.name}")
    String sysType;

    /**
     * 根据配置文件获取人脸数据库
     * @return
     */
    @Override
    public FaceDb getFaceDbOne(Integer faceType){
        QueryWrapper<FaceDb> faceDbQueryWrapper = new QueryWrapper<>();
        faceDbQueryWrapper.eq("type_name", this.sysType);
        if (faceType == 1){
            faceDbQueryWrapper.eq("face_type", 1);//学生
        }else {
            faceDbQueryWrapper.eq("face_type", 2);//教师
        }
        faceDbQueryWrapper.last("limit 1");
        FaceDb faceDb = this.getOne(faceDbQueryWrapper);
        return faceDb;
    }
}
